﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Web;

namespace LightWadf.Result
{
    public class JsonResult
    {
        private string json = null;
        public string JsonString
        {
            get
            {
                return this.json;
            }
        }

        public JsonResult(object obj)
        {
            using (var ms = new MemoryStream())
            {
                new DataContractJsonSerializer(obj.GetType()).WriteObject(ms, obj);
                this.json = Encoding.UTF8.GetString(ms.ToArray());
            }
        }
    }
}